package socket.httpserver.redirect;

public class RunRedirectServer {
    public static void main(String[] args) {
        int thePort;
        String theSite;
        try{
            theSite = args[0];
            // 删除末尾的斜杠
            if(theSite.endsWith("/")) {
                theSite = theSite.substring(0, theSite.length() - 1);
            }
        } catch (RuntimeException e) {
            System.out.println("Usage: java Redirector http://www.newsite.com/ port");
            return;
        }

        try {
            thePort = Integer.parseInt(args[1]);
        }catch (RuntimeException e) {
            thePort = 80;
        }

        Redirector redirector = new Redirector(thePort, theSite);
        redirector.start();
    }
}
